var mongoose=require('mongoose');
var Schema=mongoose.Schema; 

var ExerciseSchema=new mongoose.Schema(
	{
		schedule:Date,
		guestname:{
			type:String
		},
		mobile:String,
		prePlanname:{
			type:String
		},
		afterPlanname:String,
		prePlanContent:{
			type:Schema.Types.ObjectId,
			ref:'GuestPrePlan'
		}
	}
	);

	ExerciseSchema.pre('save',function(next){

		console.log('保存成功');
		next();
	});

ExerciseSchema.statics={
	fetch:function(cb){
		return this.find({}).sort('').exec(cb);
	},
	findById:function(id,cb){
		return this.find({_id:id}).sort('').exec(cb);
	}
}

module.exports=ExerciseSchema;